using System;
using System.Windows.Threading;
namespace MicroMsg.Common.Timer
{
	public class TimerSource
	{
		private static DispatcherTimer mSystemTimer;
		private static int mTicks;
		public static void checkSystemTimer()
		{
			if (TimerSource.mSystemTimer == null)
			{
				TimerSource.mSystemTimer = new DispatcherTimer();
				TimerSource.mSystemTimer.add_Tick(new EventHandler(TimerSource.onSystemTimerCallBack));
				TimerSource.mSystemTimer.set_Interval(new TimeSpan(0, 0, 0, 0, 1000));
				TimerSource.mSystemTimer.Start();
			}
		}
		public static void onSystemTimerCallBack(object sender, EventArgs e)
		{
			if (TimerSource.mSystemTimer == null)
			{
				return;
			}
			TimerSource.mTicks++;
			TimerService.runAllTimer();
			if ((TimerSource.mTicks + 1) % 10 == 0)
			{
				TimerService.cleanStopTimer();
			}
		}
		public static int getTicks()
		{
			return TimerSource.mTicks;
		}
	}
}
